var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/businessComponent/imp/cpts/components/ShuttleButtons.tsx
var ShuttleButtons_exports = {};
__export(ShuttleButtons_exports, {
  default: () => ShuttleButtons
});
module.exports = __toCommonJS(ShuttleButtons_exports);
var import_icons = require("@ant-design/icons");
var import_antd = require("antd");
var import_util = require("../../../../util");
var buttonStyle = { size: "small", style: { display: "block", width: 30, margin: 8 } };
function ShuttleButtons(props) {
  const {
    getRowKey,
    addResult: defaultAddResult,
    removeResult: defaultRemoveResult,
    getActiveTable,
    getResultTable,
    outRef,
    hasSelectAll = true,
    isHorizontal = false,
    rowDisable,
    subRowDisable
  } = props;
  const addResult = defaultAddResult || ((values) => {
    const selected = [];
    const existValues = getResultTable().getRows().map((r) => getRowKey(r));
    values.forEach((value) => {
      if (existValues.indexOf(getRowKey(value)) === -1) {
        const newVal = JSON.parse(JSON.stringify(value));
        selected.push(newVal);
      }
    });
    getResultTable().addRows(selected);
  });
  const removeResult = defaultRemoveResult || ((indexes) => {
    if (indexes === void 0) {
      const initData = getResultTable().getData().filter((x) => subRowDisable(x));
      getResultTable().setDataSource(initData);
    } else {
      getResultTable().deleteRows(indexes);
    }
  });
  (0, import_util.useExtendRef)(outRef, {
    toLeft: removeResult,
    toRight: addResult
  });
  buttonStyle.style.transform = isHorizontal ? "rotate(90deg)" : "rotate(0deg)";
  return /* @__PURE__ */ React.createElement(
    "div",
    {
      style: {
        display: "flex",
        alignItems: "center",
        justifyContent: "center",
        flexDirection: isHorizontal ? "row" : "column"
      }
    },
    /* @__PURE__ */ React.createElement(import_antd.Button, { ...buttonStyle, icon: /* @__PURE__ */ React.createElement(import_icons.RightOutlined, null), onClick: () => addResult(getActiveTable().getSelectedData()) }),
    hasSelectAll && /* @__PURE__ */ React.createElement(
      import_antd.Button,
      {
        ...buttonStyle,
        icon: /* @__PURE__ */ React.createElement(import_icons.DoubleRightOutlined, null),
        onClick: () => addResult(
          getActiveTable().getRows().filter((x) => !rowDisable(x))
        )
      }
    ),
    /* @__PURE__ */ React.createElement(
      import_antd.Button,
      {
        ...buttonStyle,
        icon: /* @__PURE__ */ React.createElement(import_icons.LeftOutlined, null),
        onClick: () => removeResult(getResultTable().getSelectedIndexes())
      }
    ),
    hasSelectAll && /* @__PURE__ */ React.createElement(import_antd.Button, { ...buttonStyle, icon: /* @__PURE__ */ React.createElement(import_icons.DoubleLeftOutlined, null), onClick: () => removeResult() })
  );
}
